<%--
  Created by IntelliJ IDEA.
  User: Berlin-IOU
  Date: 2017/12/5
  Time: 21:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>用户列表</title>
    <link type="text/css" href="${pageContext.request.contextPath}/assets/lib/css/bootstrap.min.css" rel="stylesheet">
    <link type="text/css" href="${pageContext.request.contextPath}/assets/lib/css/bootstrap.css" rel="stylesheet">
    <link type="text/css" href="${pageContext.request.contextPath}/assets/lib/css/bootstrap-theme.min.css"
          rel="stylesheet">
    <link type="text/css" href="${pageContext.request.contextPath}/assets/lib/css/font-awesome.min.css"
          rel="stylesheet">
    <link type="text/css" href="${pageContext.request.contextPath}/assets/lib/css/jquery.toast.css" rel="stylesheet">
</head>
<body>
<div class="container" style="margin-top: 50px">
    <a class="btn btn-danger btn-default pull-right" href="${pageContext.request.contextPath}/users/create"><i
            class="fa fa-plus-circle"></i>&nbsp;添加用户</a>
    <table class="table table-hover table-condensed">
        <caption>用户信息</caption>
        <thead>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>生日</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="userEntity" items="${USERS}" varStatus="stat">
            <tr class='${stat.index%2==0?"danger":"warning"}'>
                <td>${userEntity.id}</td>
                <td>${userEntity.name}</td>
                <td>${userEntity.gender.text}</td>
                <td>
                    <fmt:formatDate value="${userEntity.birthday}" pattern="yyyy-MM-dd"/>
                </td>
                <td>
                    <a class="btn btn-warning btn-sm"
                       href="${pageContext.request.contextPath}/users/${userEntity.id}/update"><i
                            class="fa fa-pencil-square" aria-hidden="true"></i></a>
                    <a class="btn_delete btn btn-sm btn-danger"
                       href="${pageContext.request.contextPath}/users/${userEntity.id}"><i class="fa fa-trash-o"
                                                                                           aria-hidden="true"></i></a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<script type="application/javascript"
        src="${pageContext.request.contextPath}/assets/lib/js/jquery-3.2.1.min.js"></script>
<script type="application/javascript" src="${pageContext.request.contextPath}/assets/lib/js/bootstrap.min.js"></script>
<script type="application/javascript" src="${pageContext.request.contextPath}/assets/lib/js/jquery.toast.js"></script>
<script type="application/javascript" src="${pageContext.request.contextPath}/assets/app/js/user.js"></script>
<script type="application/javascript">


    $(function(){
        <c:if test="${not empty MESSAGE}">
        $.toast({
            heading: '提示',
            text: '${MESSAGE}',
            showHideTransition: 'slide',
            icon: 'success',
            position: 'bottom-right'
        });
        </c:if>
    })

</script>
</body>
</html>
